//
//  sum.swift
//  203-移除链表元素
//
//  Created by lhc on 2023/9/14.
//

import Foundation

func sum(arr: [Int]) -> Int {
    return sumByRecursion(arr: arr, l: 0)
}

func sumByRecursion(arr: [Int], l: Int) -> Int {
    
    if l == arr.count {
        return 0
    }else {
        return arr[l] + sumByRecursion(arr: arr, l: l+1)
    }
    
    
}
